The LInteger library consists of five classes: LMisc
,
BMath
, LInteger
, LMath
, and Monty
.
Here is a brief overview of each class:
This class provides two basic methods: MemZero, and MemCopy used throughout the library.
Note:
Included in
lmisc.hxx
is a templated function called LSwap.
For some reason, g++ will not allow this to be a method for the
LMisc
class. If you get a name space collision look
here! :)
This class provides methods to the perform multiprecision arithmetic on unsigned magnitudes.
The methods in this class are made public so that programmers may use them to implement algorithms which have been designed to run most effeciently on the direct binary representations of multiprecision integers.
This class allows the instantiation of objects representing signed
multiprecision integers. Basic object manipulation, such as
copying and creation is easy with this class, and every
C++ arithmetic operation is overloaded to allow for easy
substituion in code already using int
s.
Constructors are included to create LInteger
s out of
int
s or unsigned int
s. The int()
conversion operator is overloaded to allow the use of
LInteger
s in place of int
s when precision
can be sacrificed.
This class provides methods to perform more complex arthimetic on
LInteger
s than can be acheived through
the overloaded operators. This class is a friend of the
LInteger
class. It, thus, has direct access to the binary representations of
the LInteger
s and can use this privelege, along with
calls to BMath
's methods to implement
algorithms optimized for binary
representations. On the other hand, methods in this class, can, of
course, choose to treat the LInteger
s as blackboxes.
Methods which treat their LInteger
arguments as blackboxes
will be safer since they are not making dangerous BMath
calls.
They will also be easier to code and more readable. On the other hand,
methods which take advantage of their friend
status to do
directly binary calculations may be faster. A useful strategy for people
seeking to extend the, currently meager, LMath
class
may be to, first, implement a version of the algorithm treating the
LInteger
s as blackboxes, and, then,
implement another to take advantage of the
friend
status. Agreement between the two algorithms
would, then, provide some assurance that the two algorithms were
properly implemented.
This class saves information for the conversion of magnitudes to and from Montgomery representations in certain residue classes, and provides methods to perform arithmetic on these representations.